//
//  ZRLampCollectionViewCell.m
//  简书:https://www.jianshu.com/u/043e94ca450f
//
//  Created by 黄涛 on 2018/11/20.
//  Copyright © 2018年 zero. All rights reserved.
//  顶部标签 Cell

#import "ZRLampCollectionViewCell.h"
@interface ZRLampCollectionViewCell ()

@property (nonatomic , weak) UIButton * contentBtn;

@end

@implementation ZRLampCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
     
        [self contentBtn];
    }
    return self;
}

#pragma mark - ---------------------- set & get ----------------------
- (UIButton *)contentBtn{
    if (!_contentBtn) {
        UIButton * btn = [[UIButton alloc] initWithFrame:self.bounds];
        [self.contentView addSubview:btn];
        btn.userInteractionEnabled = NO;
        btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        
        [btn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 8)];
        [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -8)];
        
        _contentBtn = btn;
    }
    return _contentBtn;
}

- (void)setLampBarItem:(ZRLampBarItem *)lampBarItem{
    _lampBarItem = lampBarItem;
    
    if(lampBarItem.title.hash) [self.contentBtn setTitle:lampBarItem.title forState:UIControlStateNormal];
    
    if (lampBarItem.selectedColor.hash) [self.contentBtn setTitleColor:lampBarItem.selectedColor forState:UIControlStateSelected];
    
    if (lampBarItem.nomalImage.hash) [self.contentBtn setImage:lampBarItem.nomalImage forState:UIControlStateNormal];
        
    if (lampBarItem.selectedImage.hash) [self.contentBtn setImage:lampBarItem.selectedImage forState:UIControlStateSelected];
    
    if (lampBarItem.textFont.hash) self.contentBtn.titleLabel.font = lampBarItem.textFont;
    

}

- (void)setIsSelected:(BOOL)isSelected{
    _isSelected = isSelected;
    
    self.contentBtn.selected = isSelected;
    
}



@end
